home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6044 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: qcunix.acc.qc.edu!h3dqc
  2. From: h3dqc@qcunix.acc.qc.edu (SHAPIRA LEEOR)
  3. Newsgroups: comp.lang.c
  4. Subject: DLL Questions
  5. Date: 22 Feb 1996 08:23:30 GMT
  6. Message-ID: <4gh962$kpb@news.cuny.edu>
  7. NNTP-Posting-Host: qcunix.acc.qc.edu
  8. X-Newsreader: TIN [version 1.1 PL9]
  9.  
  10.    I'm having a little trouble making a DLL function in Visual Basic, Im using
  11. the VB Standard Edition that one purchases via a college. I compiled the C
  12. file into a dll via Borland at school. I got no errors (after making certain
  13. that all the lib and object files were in the proper place) compiling it into
  14. a dll. I've had my share of problems calling the function in VB (including a
  15. lovely "Floating Point Error: Division by Zero" and the stanard GP error), and
  16. I'm stuck at this point. I can't seem to get VB to call the DLL function 
  17. properly. 
  18.    
  19.    I've tried compiling the DLL without the IDE, but found it to be
  20. an ardous task. If anyone can tell me specifically what obj and lib files I
  21. would need to link in, I'd appreciate it. I've used the following:
  22.  
  23. Makefile below
  24. ------------------------------------------------------------------------------
  25. testl.dll:
  26.  tlink /Twd testl.obj c0s.obj, testl.dll, ,c:\dll\import.lib c:\dll\cs.lib c:\dll\maths.lib c:\dll\fp87.lib, testl.def
  27.  
  28. testl.obj: 
  29.         bcc -c -ms! testl.cpp
  30. ------------------------------------------------------------------------------
  31. End Makefile
  32.  
  33.    In any case, please look at the code below, and thanks in advance for
  34. trudging through all this. Sorry to have had to post such strewn pieces all
  35. about.
  36.  
  37.  
  38. VB Code 
  39. ------------------------------------------------------------------------------
  40. Form1 (general)
  41. Declare Function MyFunc Lib "mydll.dll" (ByVal single1!, ByVal single2!, ByVal int1%) As Single
  42.  
  43. module1.bas (general)
  44.  Global single1 as Single
  45.  Global single2 as Single
  46.  Global int1    as Integer
  47.  Global total   as Single
  48.  
  49. Sub Form1_Click()
  50.    single1 = 50000
  51.    single2 = 2.4
  52.    int1    = 120
  53.    total = MyFunc(single1, single2, int1)
  54. *********** The above line gives me a "Bad DLL calling convention" ***********   
  55.    text1.text = total
  56. End Sub
  57. ------------------------------------------------------------------------------
  58. End VB Code
  59.  
  60.  
  61. C Code
  62. ------------------------------------------------------------------------------
  63. /*the C file itself contains the standard LibMain and WEP functions and 
  64.                this prototype for the function                            */
  65. float FAR PASCAL _export MyFunc(float single_1, float single_2, int my_int);
  66. ______________________________________________________________________________
  67. End C Code 
  68.  
  69.    Thanks again for taking the time to read this, and for your replies. Much
  70. appreciated. Please email respond if possible. I am endebted to those that 
  71. offer their assistance.
  72.  
  73.